<?xml version="1.0" encoding="utf-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:iepd="http://dps.state.tx.us/niem/exchange/ProsecutorActionReport/1.0" xmlns:tx="http://dps.state.tx.us/niem/extensions/1.0" xmlns:j="http://niem.gov/niem/domains/jxdm/4.0" xmlns:scr="http://niem.gov/niem/domains/screening/2.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:ansi-nist="http://niem.gov/niem/ansi-nist/2.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0">

<xsl:import href="TXCommon.xslt"/>

<xsl:output method="text" encoding="UTF-8"/>
	<xsl:template match="/">
		<xsl:text>&#10;</xsl:text>
		<xsl:text>                                                PROSECUTOR ACTION REPORT</xsl:text>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;                                                  ARREST/ID SECTION: </xsl:text>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;NAME:                                             </xsl:text>
		<xsl:text>DOB:           </xsl:text>
		<xsl:text>SSN:           </xsl:text>
		<xsl:text>SEX  </xsl:text>
		<xsl:text>RACE </xsl:text>
		<xsl:text>ETH  </xsl:text>
		<xsl:text>HGT  </xsl:text>
		<xsl:text>WGT  </xsl:text>
		<xsl:text>EYE  </xsl:text>
		<xsl:text>HAIR </xsl:text>
		<xsl:text>SKN  </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="50"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">NAME</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="15"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">DOB</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="15"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">SSN</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">SEX</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">RACE</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">ETH</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">HGT</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">WGT</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">EYE</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
						<xsl:with-param name="dataElem">HAIR</xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
				<xsl:with-param name="dataElem">SKN</xsl:with-param>
		</xsl:apply-templates>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Alilas(s): </xsl:text>
		<xsl:apply-templates select="//j:Subject/nc:RoleOfPersonReference">	
				<xsl:with-param name="dataElem">ALIAS</xsl:with-param>
		</xsl:apply-templates>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;GOC:      </xsl:text>
		<xsl:text>Domestic Violence Offense:    </xsl:text>
		<xsl:text>Offense Code:       </xsl:text>
		<xsl:text>Offense: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="10"/>
			<xsl:with-param name="data">
				<xsl:value-of select="//tx:ArrestCharge/j:ChargeQualifierText"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="30"/>
			<xsl:with-param name="data">
				<xsl:if test="//j:CaseDomesticViolenceIndicator='true'">Y</xsl:if>
				<xsl:if test="//j:CaseDomesticViolenceIndicator='false'">N</xsl:if>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="20"/>
			<xsl:with-param name="data">
				<xsl:value-of select="//tx:ArrestCharge/j:ChargeNCICCode"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:value-of select="//tx:ArrestCharge/j:ChargeDescriptionText"/>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Statute Citation:                       </xsl:text>
		<xsl:text>Level:    </xsl:text>
		<xsl:text>Degree:   </xsl:text>
		<xsl:text>Offense Date: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="40"/>
			<xsl:with-param name="data">
				<xsl:value-of select="//tx:ArrestCharge/j:ChargeLegalDescriptionText"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="10"/>
			<xsl:with-param name="data">
				<xsl:value-of select="//tx:ArrestCharge/j:ChargeDegreeText"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="10"/>
			<xsl:with-param name="data">
				<xsl:value-of select="//tx:ArrestCharge/j:ChargeSeverityText"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:value-of select="//tx:ArrestCharge/tx:ChargeAugmentation/tx:OffenseDate/nc:Date"/>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10; </xsl:text>
		<xsl:text>&#10; </xsl:text>
		
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;                                                        PROSECUTOR SECTION</xsl:text>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Prosecutor ORI:     </xsl:text>
		<xsl:text>Prosecutor Office: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="20"/>
			<xsl:with-param name="data">
							<xsl:value-of select="//tx:ProsecutionAgency/j:OrganizationAugmentation/j:OrganizationORIIdentification/nc:IdentificationID"/>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:value-of select="//tx:ProsecutionAgency/nc:OrganizationName"/>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Prosecutor Action Code:  </xsl:text>
		<xsl:text>Prosecutor Action Date: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="25"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">ACTIONCODE</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
			<xsl:with-param name="dataElem">ACTIONDATE</xsl:with-param>
			<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
		</xsl:apply-templates>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;GOC: </xsl:text>
		<xsl:text>Domestic Violence:  </xsl:text>
		<xsl:text>Changed Offense Code:  </xsl:text>
		<xsl:text>Offense:                      </xsl:text>
		<xsl:text>Statute Citation:       </xsl:text>
		<xsl:text>Level: </xsl:text>
		<xsl:text>Degree: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="5"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">GOC</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="20"/>
			<xsl:with-param name="data">
				<xsl:if test="//j:CaseDomesticViolenceIndicator='true'">Y</xsl:if>
				<xsl:if test="//j:CaseDomesticViolenceIndicator='false'">N</xsl:if>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="23"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">CHANGEDOFFCODE</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="30"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">OFFENSE</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="24"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">STATUTE</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="pad">
			<xsl:with-param name="amount" select="7"/>
			<xsl:with-param name="data">
				<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
					<xsl:with-param name="dataElem">LEVEL</xsl:with-param>
					<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:with-param>
		</xsl:call-template>
		<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
			<xsl:with-param name="dataElem">DEGREE</xsl:with-param>
			<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
		</xsl:apply-templates>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Additional Charges By Prosecutor, Not Present At Arrest: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:variable name="AddChg">
			<xsl:apply-templates select="//tx:ArrestProsecutionChargeAssociation">
				<xsl:with-param name="dataElem">ADDITIONALCHARGE</xsl:with-param>
				<xsl:with-param name="ArrestChgID"><xsl:value-of select="//tx:Arrest/tx:ArrestCharge/@s:id"/></xsl:with-param>
			</xsl:apply-templates>
		</xsl:variable>
		<xsl:if test="$AddChg='true'">Y</xsl:if>
		<xsl:if test="not($AddChg='true')">N</xsl:if>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>
		<xsl:text>&#10;Date: </xsl:text>
		<xsl:text>&#10;</xsl:text>
		<xsl:value-of select="//nc:DocumentCreationDate/nc:Date"/>
		<xsl:text>&#10;________________________________________________________________________________________________________________________</xsl:text>

	</xsl:template>
	
	<xsl:template match="tx:ArrestProsecutionChargeAssociation">
		<xsl:param name="dataElem"/>
		<xsl:param name="ArrestChgID"/>
		<xsl:variable name="ArrestChgRef">
			<xsl:value-of select="./tx:ArrestChargeReference/@s:ref"/>
		</xsl:variable>
		<xsl:variable name="ProsChgRef">
			<xsl:value-of select="./tx:ProsecutionChargeReference/@s:ref"/>
		</xsl:variable>
			
		<xsl:if test="$dataElem='ADDITIONALCHARGE'">
			<xsl:for-each select="//tx:CaseProsecutionCharge">
				<xsl:variable name="ProsChgID"><xsl:value-of select="@s:id"/></xsl:variable>
				<xsl:if test="not($ProsChgID=$ProsChgRef)">true</xsl:if>
			</xsl:for-each>
		</xsl:if>

		<xsl:if test="$ArrestChgRef=$ArrestChgID">
			<xsl:choose>
				<xsl:when test="$dataElem='ACTIONCODE'">
					<xsl:value-of select="./tx:ProsecutionActionCode"/>
				</xsl:when>
				<xsl:when test="$dataElem='ACTIONDATE'">
					<xsl:value-of select="./tx:ProsecutionActionDate/nc:Date"/>
				</xsl:when>
				<xsl:when test="$dataElem='GOC'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeQualifierText"/>
				</xsl:when>
				<xsl:when test="$dataElem='CHANGEDOFFCODE'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeNCICCode"/>
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/tx:ChargeAugmentation/tx:ChargeNCICTexasSuffixCode"/>
				</xsl:when>
				<xsl:when test="$dataElem='OFFENSE'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeDescriptionText"/>
				</xsl:when>
				<xsl:when test="$dataElem='STATUTE'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeLegalDescriptionText"/>
				</xsl:when>
				<xsl:when test="$dataElem='LEVEL'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeDegreeText"/>
				</xsl:when>
				<xsl:when test="$dataElem='DEGREE'">
					<xsl:value-of select="//tx:CaseProsecutionCharge[@s:id=$ProsChgRef]/j:ChargeSeverityText"/>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
	</xsl:template>


	<xsl:template match="*/nc:RoleOfPersonReference">
		<xsl:param name="dataElem"/>
		<xsl:variable name="PersonRef">
			<xsl:value-of select="@s:ref"/>
		</xsl:variable>
			
		<xsl:choose>
			<xsl:when test="$dataElem='NAME'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonName/nc:PersonGivenName"/>
				<xsl:text> </xsl:text>
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonName/nc:PersonMiddleName"/>
				<xsl:text> </xsl:text>
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonName/nc:PersonSurName"/>
			</xsl:when>
			<xsl:when test="$dataElem='SID'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonStateIdentification/nc:IdentificationID"/>
			</xsl:when>
			<xsl:when test="$dataElem='AGE'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonAgeMeasure/nc:MeasurePointValue"/>
			</xsl:when>
			<xsl:when test="$dataElem='SIGNATURE'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonDigitizedSignatureImage/nc:BinaryBase64Object"/>
			</xsl:when>
			<xsl:when test="$dataElem='DOB'">
				<xsl:call-template name="FormatDate">
					<xsl:with-param name="FullDate">
						<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonBirthDate/nc:Date"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$dataElem='SSN'">
				<xsl:call-template name="FormatSSN">
					<xsl:with-param name="FullSSN">
						<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonSSNIdentification/nc:IdentificationID"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$dataElem='RACE'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonRaceCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='SEX'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonSexCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='HGT'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonHeightMeasure"/>
			</xsl:when>
			<xsl:when test="$dataElem='WGT'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonWeightMeasure"/>
			</xsl:when>
			<xsl:when test="$dataElem='EYE'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonEyeColorCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='HAIR'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonHairColorCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='SKN'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonSkinToneCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='ETH'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/nc:PersonEthnicityCode"/>
			</xsl:when>
			<xsl:when test="$dataElem='DLN'">
				<xsl:value-of select="//*[@s:id=$PersonRef]/j:PersonAugmentation/nc:DriverLicense/nc:DriverLicenseIdentification/j:IdentificationJurisdictionNCICLISCode"/>
				<xsl:text> </xsl:text>
				<xsl:value-of select="//*[@s:id=$PersonRef]/j:PersonAugmentation/nc:DriverLicense/nc:DriverLicenseIdentification/nc:IdentificationID"/>
			</xsl:when>
			<xsl:when test="$dataElem='ADDRESS'">
				<xsl:apply-templates select="//nc:ResidenceAssociation">
					<xsl:with-param name="PersonID">
						<xsl:value-of select="$PersonRef"/>
					</xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>

			<xsl:when test="$dataElem='PHONE'">
				<xsl:apply-templates select="//nc:PersonContactInformationAssociation">
					<xsl:with-param name="PersonID">
						<xsl:value-of select="$PersonRef"/>
					</xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:when test="$dataElem='EMP'">
				<xsl:apply-templates select="//tx:PersonCurrentEmploymentAssociation">
					<xsl:with-param name="PersonID">
						<xsl:value-of select="$PersonRef"/>
					</xsl:with-param>
				</xsl:apply-templates>
		</xsl:when>
			<xsl:when test="$dataElem='BUSADDR'">
				<xsl:apply-templates select="//tx:PersonCurrentEmploymentAssociation">
					<xsl:with-param name="PersonID">
						<xsl:value-of select="$PersonRef"/>
					</xsl:with-param>
					<xsl:with-param name="dataElem">ADDRESS</xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>
			
			<xsl:when test="$dataElem='BUSPHONE'">
				<xsl:apply-templates select="//tx:PersonCurrentEmploymentAssociation">
					<xsl:with-param name="PersonID">
						<xsl:value-of select="$PersonRef"/>
					</xsl:with-param>
					<xsl:with-param name="dataElem">PHONE</xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>
			
			<xsl:when test="$dataElem='ALIAS'">
				<xsl:apply-templates select="//nc:PersonAliasIdentityAssociation">	
						<xsl:with-param name="dataElem">NAME</xsl:with-param>
						<xsl:with-param name="PersonID"><xsl:value-of select="$PersonRef"/></xsl:with-param>
				</xsl:apply-templates>
			</xsl:when>

		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="nc:PersonAliasIdentityAssociation">
		<xsl:param name="dataElem"/>
		<xsl:param name="PersonID"/>
		<xsl:variable name="PersonRef">
			<xsl:value-of select="./nc:PersonReference/@s:ref"/>
		</xsl:variable>
			
		<xsl:if test="$PersonID=$PersonRef">
			<xsl:apply-templates select="//tx:Identity">
				<xsl:with-param name="dataElem"><xsl:value-of select="$dataElem"/></xsl:with-param>
				<xsl:with-param name="IdentityRef"><xsl:value-of select="./nc:IdentityReference/@s:ref"/></xsl:with-param>
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>
	
		<xsl:template match="tx:Identity">
		<xsl:param name="dataElem"/>
		<xsl:param name="IdentityRef"/>
		<xsl:variable name="IdentityID">
			<xsl:value-of select="@s:id"/>
		</xsl:variable>
			
		<xsl:if test="$IdentityRef=$IdentityID">
			<xsl:choose>
				<xsl:when test="$dataElem='NAME'">
					<xsl:text>&#10;     </xsl:text>
					<xsl:value-of select="./tx:IdentityPersonRepresentation/nc:PersonName/nc:PersonGivenName"/>
					<xsl:text> </xsl:text>
					<xsl:value-of select="./tx:IdentityPersonRepresentation/nc:PersonName/nc:PersonMiddleName"/>
					<xsl:text> </xsl:text>
					<xsl:value-of select="./tx:IdentityPersonRepresentation/nc:PersonName/nc:PersonSurName"/>
				</xsl:when>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

	
</xsl:stylesheet>


	

